import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:taonile/config/config.dart';

import '../routers/routers.dart';

class HomeIndexTopLayout extends StatefulWidget {
  HomeIndexTopLayout({Key? key}) : super(key: key);

  @override
  HomeIndexTopLayoutState createState() => HomeIndexTopLayoutState();
}

class HomeIndexTopLayoutState extends State<HomeIndexTopLayout> {
  double opacity = 1;

  @override
  void initState() {
    super.initState();
  }

  // upDateLayoutBg(double top) {
  //   setState(() {
  //     if (top > 0.8) {
  //       top = 1;
  //     }
  //     opacity = top;
  //   });
  // }

  @override
  Widget build(BuildContext context) {
    return Stack(
      children: [
        Opacity(
          opacity: opacity,
          child: Container(
            height: 160.w,
            padding: EdgeInsets.only(top: 70.w, left: 25.w, right: 25.w),
            decoration: BoxDecoration(color: Config.colorBg2),
          ),
        ),
        Container(
          height: 160.w,
          padding: EdgeInsets.only(top: 70.w, left: 25.w, right: 25.w),
          decoration: BoxDecoration(color: Colors.transparent),
          child: Row(
            children: [
              InkWell(
                child: Icon(
                  Icons.apps_outlined,
                  size: 50.w,
                  color: opacity < 0.5 ? Config.colorWhite : Config.colorText1,
                ),
                onTap: () {
                  Routes.navigateTo(context, Routes.productClassify);
                },
              ),
              Container(
                height: 46.w,
                width: 600.w,
                decoration: BoxDecoration(
                    color: opacity < 0.5 ? const Color(0xEEFFFFFF) : Config.colorWhite,
                    borderRadius: BorderRadius.circular(24.w)),
                padding: EdgeInsets.symmetric(horizontal: 20.w),
                margin: EdgeInsets.only(left: 25.w),
                child: InkWell(
                  onTap: () {
                    Routes.navigateTo(context, Routes.searchIndex, params: {'source': '0'});
                  },
                  child: Row(
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: [
                      Icon(
                        Icons.search,
                        size: 28.w,
                        color: Config.colorText3,
                      ),
                      Padding(
                        padding: EdgeInsets.only(left: 10.w),
                      ),
                      Text(
                        "请输入商品名称",
                        style: TextStyle(fontSize: 22.sp, height: 1.3, color: Config.colorText3),
                      )
                    ],
                  ),
                ),
              ),
            ],
          ),
        )
      ],
    );
  }
}
